package Exercises;

import java.util.Scanner;

public class Task16 {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		
		int number = 0;
		
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		int e = 0;
		String str = "";
		
		while(true)
		{
			System.out.println("Please add a number: ");
		number = sc.nextInt();
			
		str = a+""+b+""+c+""+d+""+ e;

				e = number %10; 
				d = (number/10) %10; 
				c = (number/100) %10;
				b = (number/1000) %10;
				a = (number/10000) %10;
				
						
			if(a+1==b || b+1==c || c+1==d || d+1==e)
			{
				System.out.println("Last available number: "+str);
				 break;
			}
			
		}
		
		
		
		
		
	}

}
